﻿@{
    ViewBag.BodyClass = "page-aside-fixed page-aside-left site-contabs-open site-menubar-unfold ";
}

<div class="page animation-fade">
    <div class="page-aside">

        <div class="page-aside-switch">
            <i class="icon wb-chevron-left" aria-hidden="true"></i>
            <i class="icon wb-chevron-right" aria-hidden="true"></i>
        </div>

        <div class="page-aside-inner page-aside-scroll" data-plugin="mCustomScrollbar">
            <div data-role="container">
                <div data-role="content">
                    <section class="page-aside-section">
                        <div class="list-group">
                            <a class="list-group-item" href="javascript:;" onclick="App.pId = ''; adminList.refresh({Menu_ID:null});">
                                <i class="fa fa-eye" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;&nbsp;所有一级
                            </a>
                        </div>
                    </section>
                    <section class="page-aside-section">
                        <!--标签树-->
                        <ul id="tree" class="ztree"></ul>
                    </section>
                </div>
            </div>
        </div>
    </div>
    <div class="page-main">
        <div class="page-content">

            <!--高级检索部分-->
            <div class="panel" id="panelSearch">
                <div class="panel-heading">
                    <h3 class="panel-title">高级检索</h3>
                </div>
                <div class="panel-body">
                    <form action="javascript:void(0)" class="form-row">
                        <div class="col-sm-3">
                            <h4 class="example-title">菜单名</h4>
                            <input type="text" class="form-control" name="Menu_Name" placeholder="请输入 菜单名">
                        </div>
                    </form>

                </div>
                <div class="panel-footer text-right">
                    <button class="btn btn-primary" onclick="adminList.search()">检索</button>&nbsp;&nbsp;
                    <button class="btn btn-success" onclick="adminList.resetSearch()">重置</button>&nbsp;&nbsp;
                    <button class="btn btn-danger" onclick="adminList.panelSearch()">关闭</button>
                </div>
            </div>

            <!--列表-->
            <div class="panel">
                <div class="panel-heading">
                    <div class="col-sm-12 pl-25 pr-25 pt-15 pb-10">
                        <button type="button" class="btn btn-primary" onclick="window.location=window.location">
                            <i class="fa fa-rotate-right"></i>&nbsp;刷新
                        </button>
                        <button type="button" class="btn btn-primary" data-power="Search" name="search" onclick="adminList.panelSearch()">
                            <i class="fa fa-search"></i>&nbsp;检索
                        </button>
                        <button type="button" class="btn btn-primary" data-power="Add" name="add" onclick="App.Form('add')">
                            <i class="fa fa-plus"></i>&nbsp;添加
                        </button>
                        <button type="button" class="btn btn-primary" data-power="Edit" name="edit" onclick="App.Form('edit')" disabled="disabled">
                            <i class="fa fa-pencil"></i>&nbsp;修改
                        </button>
                        <button type="button" class="btn btn-primary" data-power="Delete" name="delete" onclick="App.Delete()" disabled="disabled">
                            <i class="fa fa-trash"></i>&nbsp;删除
                        </button>
                        <a class="btn btn-primary" target="_blank" href="" data-power="GetExcel" name="getExcel" onclick="App.ExportExcel()">
                            <i class="fa fa-file-excel-o"></i>&nbsp;导出 Excel
                        </a>
                    </div>
                </div>
                <div class="panel-body container-fluid pb-0">

                    <!--表格-->
                    <table class="table table-hover" id="bootStrapTable"></table>

                </div>
            </div>



        </div>
    </div>
</div>


@*<div id="hzy-container">

        <div class="page-content">


            <div class="page-aside">
                <div class="padding-10 text-center" style="border-bottom:1px solid #ccc; cursor:pointer; font-size:22px;" onclick="App.pId = ''; adminList.refresh({Menu_ID:null});">查看所有一级菜单</div>
                <!--标签树-->
                <ul id="tree" class="ztree" style=" height:calc(100vh - 72px); overflow-y:auto;"></ul>
            </div>
            <div class="page-main" style="overflow:visible;">

                <!--高级检索部分-->
                <div class="panel" id="panelSearch">
                    <div class="panel-heading">
                        <h3 class="panel-title">高级检索</h3>
                    </div>
                    <div class="panel-body">

                        <form action="javascript:void(0)">
                            <div class="col-sm-3">
                                <h4 class="example-title">菜单名</h4>
                                <input type="text" class="form-control" name="Menu_Name" placeholder="请输入 菜单名">
                            </div>
                        </form>

                    </div>
                    <div class="panel-footer text-right">
                        <button class="btn btn-primary btn-outline" onclick="adminList.search()">检索</button>&nbsp;&nbsp;
                        <button class="btn btn-success btn-outline" onclick="adminList.resetSearch()">重置</button>&nbsp;&nbsp;
                        <button class="btn btn-danger btn-outline" onclick="adminList.panelSearch()">关闭</button>
                    </div>
                </div>
                <!--列表部分-->
                <div class="panel">
                    <div class="panel-body" style="padding: 10px;padding-bottom:0;">


                        <div class="row">
                            <div class="col-sm-12">
                                <div class="btn-group">
                                    <button type="button" class="btn btn-default btn-outline" onclick="window.location=window.location">
                                        <i class="fa fa-rotate-right"></i>&nbsp;刷新
                                    </button>
                                    <button type="button" class="btn btn-default btn-outline" data-power="Search" name="search" onclick="adminList.panelSearch()">
                                        <i class="fa fa-search"></i>&nbsp;检索
                                    </button>
                                    <button type="button" class="btn btn-default btn-outline" data-power="Add" name="add" onclick="App.Form('add')">
                                        <i class="fa fa-plus"></i>&nbsp;添加
                                    </button>
                                    <button type="button" class="btn btn-default btn-outline" data-power="Edit" name="edit" onclick="App.Form('edit')" disabled="disabled">
                                        <i class="fa fa-pencil"></i>&nbsp;修改
                                    </button>
                                    <button type="button" class="btn btn-default btn-outline" data-power="Delete" name="delete" onclick="App.Delete()" disabled="disabled">
                                        <i class="fa fa-trash"></i>&nbsp;删除
                                    </button>
                                    <a class="btn btn-default btn-outline" target="_blank" href="" data-power="GetExcel" name="getExcel" onclick="App.ExportExcel()">
                                        <i class="fa fa-file-excel-o"></i>&nbsp;导出 Excel
                                    </a>
                                </div>

                            </div>
                            <div class="col-sm-12 margin-top-5">
                                <!--表格-->
                                <table class="table table-bordered table-hover" id="bootStrapTable"></table>
                            </div>
                        </div>


                    </div>
                </div>

            </div>



        </div>

    </div>*@

@section css{
    <link href="~/Resource/Admin/lib/zTree/css/metroStyle/metroStyle.css" rel="stylesheet" />
    <style type="text/css">
    </style>
}
@section js{
    <script src="~/Resource/Admin/lib/bootstrap-table-develop/src/bootstrap-table.js"></script>
    <script src="~/Resource/Admin/lib/bootstrap-table-develop/src/locale/bootstrap-table-zh-CN.js"></script>
    <script src="~/Resource/Admin/js/admin-list.js"></script>
    <!--else-->
    <script src="~/Resource/Admin/lib/zTree/js/jquery.ztree.all.min.js"></script>
    <script type="text/javascript">
        var FormID = "@ViewData["formWindowName"]";
        var thisWindowName = "@ViewData["thisWindowName"]";

        $(function () {

            App.Init();

        });

        var App = {
            Init: function () {
                admin.ajax({
                    url: "@Url.Action("GetDataSource")",
                    data: { rows: 1 },
                    success: function (r) {
                        var adminBootStrapTable = adminList.bootStrapTable({
                            url: "@Url.Action("GetDataSource")",
                            columns: r.column,
                            queryParams: function (p) {
                                p.Menu_ID = App.pId;
                                return p;
                            }
                        });
                    }
                });

                App.GetMenuAndFunctionTree();

            },
            Form: function (tag) {
                var rows = adminList.selectRows();
                var url = "@Url.Action("Info")";
                if (tag == "add") {
                    url = url + "/?ID=&pId=" + App.pId;
                } else {
                    url = url + "/?ID=" + rows[0]._ukid + "&pId" + App.pId;
                }
                adminList.form({
                    id: FormID,
                    parentIframeName: thisWindowName,
                    url: url,
                    width: "800px",
                    height: "600px",
                    btn: false,
                });
            },
            Delete: function () {
                adminList.delete('@Url.Action("Delete")', function () {
                    App.Refresh();
                    console.log("删除完成!");
                });
            },
            ExportExcel: function () {
                adminList.exportExcel('@Url.Action("ExportExcel")');
            },
            Refresh: function (data) {
                adminList.refresh(data);
                App.GetMenuAndFunctionTree();
            },
            pId: "",
            GetMenuAndFunctionTree: function () {
                admin.ajax({
                    url: "@Url.Action("GetMenuAndFunctionTree")",
                    success: function (r) {
                        var setting = {
                            check: {
                                enable: true,
                                chkboxType: { "Y": "ps", "N": "ps" },
                                chkDisabled: true
                            },
                            view: {
                                dblClickExpand: true
                            },
                            data: {
                                simpleData: {
                                    enable: true,
                                    idKey: "id",
                                    pIdKey: "pId",
                                    rootPId: 0,
                                },
                                key: { checked: 'checked' }
                            },
                            callback: {
                                onClick: function (event, treeId, treeNode) {
                                    adminList.refresh({
                                        Menu_ID: treeNode.id
                                    });
                                    App.pId = treeNode.id;
                                },
                            }
                        };
                        zTree = $.fn.zTree.init($("#tree"), setting, r.value);
                        //zTree.expandAll(true);//展开所有

                    }
                });

            },

        };
    </script>
}
